unit stl_types;
interface

type

DWORD = cardinal;
QWORD = int64;
BOOL = boolean;

  TD = packed record
    hndl: DWORD;
    file_path: string;
    p_init: procedure(const Width, Height: Longint; const WAV: POINTER; const FFT: POINTER);
    p_run: procedure(const hndl: Thandle);
    p_free: procedure;
  end;
type STLTYPE = string;
type STLTP =
record
  id:byte;
  pnt:Pointer;
end;

const _int = 0;
    _ptr = _int + 1;
  _char = _ptr + 1;
  _bool = _char + 1;
  _string = _bool + 1;
//Vector-Based containers
  _container = _string + 1;
  __vector = _container + 1;
  _queue = __vector + 1;
  _deq = _queue + 1;
  _stack = _deq + 1;
  _list = _stack + 1;

//Tree-Based containers
  _set = _list + 1;
  _heap = _set + 1;
  _rb_tree= _heap + 1;
  _d_tree = _rb_tree + 1;
  _p_tree= _d_tree + 1;
  _map = _p_tree + 1;
  _last = _map;
 _size =_map;
Type Trc = record
  str: string;//shrt-name for DEBUG
  ptr: pointer;
  id:longint;
end;

var
 tps : array[0 .. _size] of  byte = (_int,_ptr, _char, _bool,_string, _container,__vector,_queue,_deq,_stack,_list,_set, _heap,_rb_tree,
  _d_tree,_p_tree, _map);
  _None: StlType;
implementation
uses SysUtils;
var
  inited:boolean=false;
  size:longint;
procedure INIT_TYPES;
begin
  exit;
end;

function b_search(var i:Longint):longint;
var
  l, r, m :longint;
begin
  l := 1;
  r := size;
  while (l  < r) do
  begin
    m := (l + r) div 2;
    if (tps[m] = i) then
    begin
      b_search := m;
      exit;
    end;
    if (tps[m] > i) then
      r := m
    else
      l := m;
  end;
 if (tps[l] = m) then
   b_search := l
 else
   b_search := -1;
end;

function chk_tp(a:STLTP):boolean;
var
    i: byte;
begin
  chk_tp := (a.id <= _size);
end;

function GetPointer(const x: byte):pointer;
{const
  b: tps; }
begin
  if (not inited) then Init_Types;
end;

function Unname_type(const a:STLTP): Pointer;
var
  res: Pointer;
begin
  res := nil;
  if (not chk_tp(a)) then
   Unname_type := nil
  else
    begin
      Unname_type :=GetPointer(a.id);
    end;
end;
initialization
	fillchar(_none, sizeof(_none), 0);
end.
